home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / LEDA / incl / LEDA.020+881 / node_set.h < prev    next >
C/C++ Source or Header  |  1994-08-05  |  1KB  |  44 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  3.1c
  4. +
  5. +
  6. +  node_set.h
  7. +
  8. +
  9. +  Copyright (c) 1994  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15. #ifndef LEDA_NODE_SET_H
  16. #define LEDA_NODE_SET_H
  17.  
  18. #include <LEDA/graph.h>
  19.  
  20. //------------------------------------------------------------------------------
  21. // node_set  
  22. //------------------------------------------------------------------------------
  23.  
  24. class node_set {
  25. graph* g;
  26. list<node> L;
  27. graph_array(node) A;
  28. public:
  29. void insert(node x)  { if (A.inf(x) == nil) A.entry(x) = Convert(L.append(x)); }
  30. void del(node x)     { if (A.inf(x) != nil) 
  31.                         { L.del(list_item(A.inf(x))); A.entry(x) = nil;} 
  32.                       }
  33. bool member(node x)      { return (A.inf(x) != nil); }
  34. node choose()  const     { return L.head(); }
  35. int  size()    const     { return L.length(); }
  36. bool empty()   const     { return L.empty(); }
  37. void clear()             { L.clear(); A.init(*g,nil); }
  38. node_set(const graph& G) { g = (graph*)&G; A.init(G,nil);}
  39. ~node_set()              { L.clear(); A.clear(); }
  40. };
  41.  
  42. #endif
  43.